package org.edu.modules.sxjy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.edu.common.api.vo.Result;
import org.edu.common.system.vo.LoginUser;
import org.edu.modules.sxjy.entity.OssFile;
import org.edu.modules.sxjy.entity.VeCommon;
import org.edu.modules.sxjy.entity.VeCompany;
import org.edu.modules.sxjy.entity.VeCompanyUser;
import org.edu.modules.sxjy.entity.VeEstate;
import org.edu.modules.sxjy.entity.VePost;
import org.edu.modules.sxjy.entity.VeTrade;
import org.edu.modules.sxjy.feign.VeCommonClient;
import org.edu.modules.sxjy.mapper.VeCompanyMapper;
import org.edu.modules.sxjy.oss.FileDTO;
import org.edu.modules.sxjy.service.IOssFileService;
import org.edu.modules.sxjy.service.IVeCompanyService;
import org.edu.modules.sxjy.service.IVeCompanyUserService;
import org.edu.modules.sxjy.service.IVeEstateService;
import org.edu.modules.sxjy.service.IVePostService;
import org.edu.modules.sxjy.service.IVeTradeService;
import org.edu.modules.sxjy.utils.PageResponseResult;
import org.edu.modules.sxjy.utils.PagingUtils;
import org.edu.modules.sxjy.vo.VeCompanyAddVo;
import org.edu.modules.sxjy.vo.VeCompanyUpdateVo;
import org.edu.modules.sxjy.vo.VeCompanyUserVo;
import org.edu.modules.sxjy.vo.VeCompanyVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VeCompanyServiceImpl
        extends ServiceImpl<VeCompanyMapper, VeCompany>
        implements IVeCompanyService
{
    @Autowired
    VeCompanyMapper veCompanyMapper;
    @Autowired
    private IVeCompanyService veCompanyService;
    @Autowired
    private IVeTradeService veTradeService;
    @Autowired
    private IVeEstateService veEstateService;
    @Autowired
    private IVeCompanyUserService veCompanyUserService;
    @Autowired
    private IOssFileService ossFileService;
    @Autowired
    private VeCommonClient veCommonClient;
    @Autowired
    private IVePostService vePostService;

    public List<VeCompanyVo> selectAll(VeCompanyVo veCompanyVo, Integer pageNo, Integer pageSize, VeCommon veCommon)
    {
        List<VeCompanyVo> veCompanyVoList = new ArrayList();
        VeCompanyUser veCompanyUser;
        if ((veCommon.getUserType().contains("3")) || (veCommon.getUserType().contains("4")))
        {
            veCompanyUser = this.veCompanyMapper.getCpUserByUserId(veCommon.getUserId());
            if ((veCompanyUser != null) && (!"".equals(veCompanyUser)))
            {
                veCommon.setCpId(veCompanyUser.getCpId());
                veCompanyVoList = this.veCompanyMapper.selectAll(veCompanyVo, pageNo, pageSize, veCommon);
            }
            else if ((veCompanyUser == null) && ("".equals(veCompanyUser)))
            {
                veCompanyVoList = new ArrayList();
            }
        }
        else
        {
            veCompanyVoList = this.veCompanyMapper.selectAll(veCompanyVo, pageNo, pageSize, veCommon);
        }
        if ((veCompanyVoList != null) && (veCompanyVoList.size() > 0)) {
            //lbh 2024/07/31  veCompanyUser >> Iterator veCompany ,for循环内所有veCompanyUser >> veCompany
            for (Iterator veCompany = veCompanyVoList.iterator(); veCompany.hasNext();)
            {
                //lbh 2024/07/31 companyVo >> VeCompanyVo companyVo
                VeCompanyVo companyVo = (VeCompanyVo)veCompany.next();
                if ((companyVo != null) && (!"".equals(companyVo)))
                {
                    Result<?> natureResult = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYXZ", companyVo.getNature());
                    Object result = natureResult.getResult();
                    List<Object> natureObject = (List)result;
                    for (Object o : natureObject)
                    {
                        Map map = (Map)o;
                        if (map.get("code").equals(companyVo.getNature())) {
                            companyVo.setNature((String)map.get("title"));
                        }
                    }
                }
                if ((companyVo != null) && (!"".equals(companyVo)))
                {
                    Result<?> scaleResult = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYGM", companyVo.getScale());
                    if (scaleResult.getCode().equals(Integer.valueOf(200)))
                    {
                        Object result = scaleResult.getResult();
                        List<Object> scaleObject = (List)result;
                        for (Object o : scaleObject)
                        {
                            Map map = (Map)o;
                            if (map.get("code").equals(companyVo.getScale())) {
                                companyVo.setScale((String)map.get("title"));
                            }
                        }
                    }
                }
            }
        }
        VeCompanyVo companyVo;
        return veCompanyVoList;
    }

    public List<VeCompanyVo> selectAlls()
    {
        List<VeCompanyVo> veCompanyVos = this.veCompanyMapper.selectAlls();
        for (VeCompanyVo veCompanyVo : veCompanyVos) {
            if (veCompanyVo.getStatus() == 1) {
                veCompanyVo.setStatuss("启用");
            } else if (veCompanyVo.getStatus() == 0) {
                veCompanyVo.setStatuss("禁用");
            }
        }
        return veCompanyVos;
    }

    public int getFirmNameId(String name)
    {
        int firmNameId = this.veCompanyMapper.getFirmNameId(name);
        return firmNameId;
    }

    public List<VeCompanyUserVo> getPrincipalName(int cpId)
    {
        return this.veCompanyMapper.getPrincipalName(cpId);
    }

    public boolean setExcel(VeCompanyVo veCompanyVo)
    {
        VeCompany veCompany = new VeCompany();
        if (veCompanyVo.getNatureTitle() != null)
        {
            Result<?> natureResult = this.veCommonClient.queryDictDataByModelCodeTitle("09d5e1e7f9b049008eee645c783a1d67", "QYXZ", veCompanyVo.getNatureTitle());
            Object natureObject = natureResult.getResult();
            List<Object> natureList = (List)natureObject;
            if (natureList != null) {
                for (Object o : natureList)
                {
                    Map map = (Map)o;
                    if (map.get("title").equals(veCompanyVo.getNatureTitle())) {
                        veCompany.setNature((String)map.get("code"));
                    }
                }
            } else {
                return false;
            }
        }
        if (veCompanyVo.getScaleTitle() != null)
        {
            Result<?> scaleResult = this.veCommonClient.queryDictDataByModelCodeTitle("09d5e1e7f9b049008eee645c783a1d67", "QYGM", veCompanyVo.getScaleTitle());
            Object scaleObject = scaleResult.getResult();
            List<Object> scaleList = (List)scaleObject;
            if (scaleList != null) {
                for (Object o : scaleList)
                {
                    Map map = (Map)o;
                    if (map.get("title").equals(veCompanyVo.getScaleTitle())) {
                        veCompany.setScale((String)map.get("code"));
                    }
                }
            } else {
                return false;
            }
        }
        if (veCompanyVo.getTradeTitle() != null)
        {
            VeTrade veTrade = this.veTradeService.getTrade(veCompanyVo.getTradeTitle());
            if (veTrade != null) {
                veCompany.setTradeId(veTrade.getId());
            } else {
                return false;
            }
        }
        if (veCompanyVo.getEstateTitle() != null)
        {
            VeEstate veEstate = this.veEstateService.getEstate(veCompanyVo.getEstateTitle());
            if (veEstate != null) {
                veCompany.setEstateId(veEstate.getId());
            } else {
                return false;
            }
        }
        veCompany.setName(veCompanyVo.getName());

        LoginUser user = (LoginUser)SecurityUtils.getSubject().getPrincipal();

        veCompany.setCreateUserId(user.getId());

        veCompany.setCreateTime(System.currentTimeMillis());

        veCompany.setTerminalId(1);

        veCompany.setLinkman(veCompanyVo.getLinkman());

        veCompany.setTel(veCompanyVo.getTel());

        veCompany.setFax(veCompanyVo.getFax());

        veCompany.setEmail(veCompanyVo.getEmail());

        veCompany.setAddress(veCompanyVo.getAddress());
        if (veCompanyVo.getIsCity().equals("是")) {
            veCompany.setIsCity(1);
        } else if (veCompanyVo.getIsCity().equals("否")) {
            veCompany.setIsCity(0);
        }
        if (veCompanyVo.getIsWorld500().equals("是")) {
            veCompany.setIsWorld500(1);
        } else if (veCompanyVo.getIsWorld500().equals("否")) {
            veCompany.setIsWorld500(0);
        }
        if (veCompanyVo.getIsHzdw().equals("是")) {
            veCompany.setIsHzdw(1);
        } else if (veCompanyVo.getIsHzdw().equals("否")) {
            veCompany.setIsHzdw(0);
        }
        if (veCompanyVo.getIsSxijd().equals("是")) {
            veCompany.setIsSxijd(1);
        } else if (veCompanyVo.getIsSxijd().equals("否")) {
            veCompany.setIsSxijd(0);
        }
        String[] split = veCompanyVo.getDistricts().split("-");

        veCompany.setProvince(split[0]);

        veCompany.setCity(split[1]);

        veCompany.setDistrict(split[2]);

        this.veCompanyService.save(veCompany);
        return true;
    }

    public List<VeCompanyVo> exportXls(VeCommon veCommon)
    {
        List<VeCompanyVo> veCompanyVoList = new ArrayList();
        VeCompanyUser veCompanyUser;
        if ((veCommon.getUserType().contains("3")) || (veCommon.getUserType().contains("4")))
        {
            veCompanyUser = this.veCompanyMapper.getCpUserByUserId(veCommon.getUserId());
            if ((veCompanyUser != null) && (!"".equals(veCompanyUser)))
            {
                veCommon.setCpId(veCompanyUser.getCpId());
                veCompanyVoList = this.veCompanyMapper.exportXls(veCommon);
            }
            else if ((veCompanyUser == null) && ("".equals(veCompanyUser)))
            {
                veCompanyVoList = new ArrayList();
            }
        }
        else
        {
            veCompanyVoList = this.veCompanyMapper.exportXls(veCommon);
        }
        for (VeCompanyVo veCompanyVo : veCompanyVoList)
        {
            VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(veCompanyVo.getId()));
            BeanUtils.copyProperties(veCompany, veCompanyVo);
            if (veCompany.getNature() != null)
            {
                Result<?> natureList = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYXZ", veCompany.getNature());
                List<Object> natureResult = (List)natureList.getResult();
                for (Object o : natureResult)
                {
                    Map map = (Map)o;
                    if (map.get("code").equals(veCompany.getNature())) {
                        veCompanyVo.setNatureTitle((String)map.get("title"));
                    }
                }
            }
            if (veCompany.getScale() != null)
            {
                Result<?> scaleList = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYGM", veCompany.getScale());
                List<Object> scaleResult = (List)scaleList.getResult();
                for (Object o : scaleResult)
                {
                    Map map = (Map)o;
                    if (map.get("code").equals(veCompany.getScale())) {
                        veCompanyVo.setScaleTitle((String)map.get("title"));
                    }
                }
            }
            VeTrade veTrade = (VeTrade)this.veTradeService.getById(Integer.valueOf(veCompany.getTradeId()));
            if (veTrade != null) {
                veCompanyVo.setTradeTitle(veTrade.getTitle());
            }
            VeEstate veEstate = (VeEstate)this.veEstateService.getById(Integer.valueOf(veCompany.getEstateId()));
            if (veEstate != null) {
                veCompanyVo.setEstateTitle(veEstate.getTitle());
            }
            if (veCompany.getIsCity() == 1) {
                veCompanyVo.setIsCity("是");
            } else if (veCompany.getIsCity() == 0) {
                veCompanyVo.setIsCity("否");
            }
            if (veCompany.getIsWorld500() == 1) {
                veCompanyVo.setIsWorld500("是");
            } else if (veCompany.getIsWorld500() == 0) {
                veCompanyVo.setIsWorld500("否");
            }
            if (veCompany.getIsHzdw() == 1) {
                veCompanyVo.setIsHzdw("是");
            } else if (veCompany.getIsHzdw() == 0) {
                veCompanyVo.setIsHzdw("否");
            }
            if (veCompany.getIsSxijd() == 1) {
                veCompanyVo.setIsSxijd("是");
            } else if (veCompany.getIsSxijd() == 0) {
                veCompanyVo.setIsSxijd("否");
            }
            veCompanyVo.setDistricts(veCompany.getDistrict());
        }
        return veCompanyVoList;
    }

    public int getSumPage(VeCompanyVo veCompanyVo, VeCommon veCommon)
    {
        return this.veCompanyMapper.getSumPage(veCompanyVo, veCommon);
    }

    public void updateStart(List<VeCompany> veCompany)
    {
        for (VeCompany company : veCompany)
        {
            company.setStatus(1);
            this.veCompanyService.updateById(company);
        }
    }

    public void updateStop(List<VeCompany> veCompany)
    {
        for (VeCompany company : veCompany)
        {
            company.setStatus(0);
            this.veCompanyService.updateById(company);
        }
    }

    public String getCpNameById(int cpId)
    {
        return this.veCompanyMapper.getCpNameById(cpId);
    }

    public VeCompanyUpdateVo editEcho(int id)
    {
        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(id));

        VeCompanyUpdateVo veCompanyUpdateVo = new VeCompanyUpdateVo();
        if ((veCompany == null) || ("".equals(veCompany))) {
            return veCompanyUpdateVo;
        }
        BeanUtils.copyProperties(veCompany, veCompanyUpdateVo);

        veCompanyUpdateVo.setProvince(veCompany.getProvince());

        veCompanyUpdateVo.setCity(veCompany.getCity());

        veCompanyUpdateVo.setDistrict(veCompany.getDistrict());


        List<OssFile> ossFileList = this.ossFileService.list();
        for (OssFile ossFile : ossFileList) {
            if ((ossFile != null) && (!"".equals(ossFile)) &&
                    (ossFile.getId().equals(((VeCompany)this.veCompanyService.getById(Integer.valueOf(id))).getCoverId()))) {
                veCompanyUpdateVo.setCoverUrl(ossFile.getUrl());
            }
        }
        veCompanyUpdateVo.setStatus(veCompany.getStatus());
        if (veCompany.getNature() != null)
        {
            Object natureResult = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYXZ", veCompany.getNature());
            Object result = ((Result)natureResult).getResult();
            List<Object> natureObject = (List)result;
            for (Object o : natureObject)
            {
                Map map = (Map)o;
                if (map.get("code").equals(veCompany.getNature())) {
                    veCompany.setNature((String)map.get("title"));
                }
            }
        }
        if (veCompany.getScale() != null)
        {
            Object scaleResult = this.veCommonClient.queryDictDataByModelCode("09d5e1e7f9b049008eee645c783a1d67", "QYGM", veCompany.getScale());
            Object result = ((Result)scaleResult).getResult();
            List<Object> scaleObject = (List)result;
            for (Object o : scaleObject)
            {
                Map map = (Map)o;
                if (map.get("code").equals(veCompany.getScale())) {
                    veCompany.setScale((String)map.get("title"));
                }
            }
        }
        veCompanyUpdateVo.setTradeId(veCompany.getTradeId());

        veCompanyUpdateVo.setEstateId(veCompany.getEstateId());


        return veCompanyUpdateVo;
    }

    public void edit(VeCompanyUpdateVo veCompanyUpdateVo)
    {
        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(veCompanyUpdateVo.getId()));




        LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();

        BeanUtils.copyProperties(veCompanyUpdateVo, veCompany);


        veCompany.setProvince(veCompanyUpdateVo.getProvince());

        veCompany.setCity(veCompanyUpdateVo.getCity());

        veCompany.setDistrict(veCompanyUpdateVo.getDistrict());


        veCompany.setStatus(veCompanyUpdateVo.getStatus());


        veCompany.setNature(veCompanyUpdateVo.getNature());



        veCompany.setStatus(veCompanyUpdateVo.getStatus());




        veCompany.setTradeId(veCompanyUpdateVo.getTradeId());

        veCompany.setEstateId(veCompanyUpdateVo.getEstateId());
        if (veCompany.getCoverId() != null)
        {
            if (veCompanyUpdateVo.getCoverUrl() != null)
            {
                OssFile ossFile = (OssFile)this.ossFileService.getById(((VeCompany)this.veCompanyService.getById(Integer.valueOf(veCompanyUpdateVo.getId()))).getCoverId());
                if (!ossFile.getUrl().equals(veCompanyUpdateVo.getCoverUrl()))
                {
                    ossFile.setUrl(veCompanyUpdateVo.getCoverUrl());

                    String url = veCompanyUpdateVo.getCoverUrl();
                    ossFile.setFileName(url.substring(url.lastIndexOf("_") + 1));

                    ossFile.setUpdateBy(loginUser.getRealname());

                    ossFile.setUpdateTime(new Date());

                    this.ossFileService.updateById(ossFile);
                }
            }
        }
        else if (veCompanyUpdateVo.getCoverUrl() != null)
        {
            OssFile ossFiles = new OssFile();

            ossFiles.setUrl(veCompanyUpdateVo.getCoverUrl());

            String url = veCompanyUpdateVo.getCoverUrl();
            ossFiles.setFileName(url.substring(url.lastIndexOf("_") + 1));

            ossFiles.setCreateBy(loginUser.getRealname());

            ossFiles.setCreateTime(new Date());

            ossFiles.setUpdateBy(loginUser.getRealname());

            ossFiles.setUpdateTime(new Date());

            this.ossFileService.save(ossFiles);


            String ossFileIdByUrl = this.veCompanyMapper.getOssFileIdByUrl(ossFiles.getUrl());
            if ((ossFileIdByUrl != null) && (!"".equals(ossFileIdByUrl))) {
                veCompany.setCoverId(ossFileIdByUrl);
            }
        }
        this.veCompanyService.updateById(veCompany);
    }

    public void saves(VeCompanyAddVo veCompanyAddVo)
    {
        VeCompany veCompany = new VeCompany();

        LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();

        veCompany.setName(veCompanyAddVo.getName());

        veCompany.setLinkman(veCompanyAddVo.getLinkman());

        veCompany.setTel(veCompanyAddVo.getTel());

        veCompany.setFax(veCompanyAddVo.getFax());

        veCompany.setEmail(veCompanyAddVo.getEmail());

        veCompany.setAddress(veCompanyAddVo.getAddress());

        veCompany.setStatus(veCompanyAddVo.getStatus());
        if (veCompanyAddVo.getFileDTO().getWebUrl() != null)
        {
            OssFile ossFile = new OssFile();

            ossFile.setUrl(veCompanyAddVo.getFileDTO().getWebUrl());

            String url = veCompanyAddVo.getFileDTO().getWebUrl();
            ossFile.setFileName(url.substring(url.lastIndexOf("-") + 1));


            ossFile.setCreateBy(loginUser.getRealname());

            ossFile.setCreateTime(new Date());

            ossFile.setUpdateBy(loginUser.getRealname());

            ossFile.setUpdateTime(new Date());

            this.ossFileService.save(ossFile);


            String ossFileIdByUrl = this.veCompanyMapper.getOssFileIdByUrl(ossFile.getUrl());
            if ((ossFileIdByUrl != null) && (!"".equals(ossFileIdByUrl))) {
                veCompany.setCoverId(ossFileIdByUrl);
            }
        }
        veCompany.setProvince(veCompanyAddVo.getProvince());

        veCompany.setCity(veCompanyAddVo.getCity());

        veCompany.setDistrict(veCompanyAddVo.getDistrict());



        veCompany.setIsCity(veCompanyAddVo.getIsCity());

        veCompany.setIsWorld500(veCompanyAddVo.getIsWorld500());





        veCompany.setNature(veCompanyAddVo.getNature());




        veCompany.setScale(veCompanyAddVo.getScale());





        veCompany.setTradeId(veCompanyAddVo.getTradeId());

        veCompany.setEstateId(veCompanyAddVo.getEstateId());

        veCompany.setIsHzdw(veCompanyAddVo.getIsHzdw());

        veCompany.setIsSxijd(veCompanyAddVo.getIsSxijd());



        veCompany.setCreateUserId(loginUser.getId());

        veCompany.setCreateTime(System.currentTimeMillis());

        veCompany.setTerminalId(1);

        this.veCompanyService.save(veCompany);
    }

    public int setPrincipalEcho(int id)
    {
        VeCompany veCompany = (VeCompany)this.veCompanyService.getById(Integer.valueOf(id));

        List<VeCompanyUser> veCompanyUserList = this.veCompanyUserService.list();
        if ((veCompanyUserList != null) && (!"".equals(veCompanyUserList))) {
            for (VeCompanyUser veCompanyUser : veCompanyUserList) {
                if ((veCompanyUser.getCpId() == veCompany.getId()) &&
                        (veCompanyUser.getUserId().equals(veCompany.getUserId())) &&
                        (veCompanyUser.getType().equals("cpadmin"))) {
                    return veCompanyUser.getId();
                }
            }
        }
        return 0;
    }

    public Result<?> unityRemoveBatch(String ids)
    {
        List<String> stringList = Arrays.asList(ids.split(","));
        if ((stringList != null) && (stringList.size() > 0))
        {
            for (String cpId : stringList)
            {
                Integer stuId = this.veCompanyMapper.getPracticeStuIdByCpId(cpId);
                if ((stuId != null) && (!"".equals(stuId)))
                {
                    Integer cpIsStuInfo = this.veCompanyMapper.cpIsStuInfo(stuId);
                    if (cpIsStuInfo.intValue() > 0) {
                        return Result.error("该企业已经有学生实习信息，不能被删除只能禁用");
                    }
                    unityRemoveBatchByCpid(cpId);
                }
                else
                {
                    unityRemoveBatchByCpid(cpId);
                }
            }
            return Result.OK("批量删除成功!");
        }
        return Result.error("企业信息有误");
    }

    public Map getCompanyByUserId(String userId)
    {
        VeCompanyUser veCompanyUser = this.veCompanyMapper.getCpUserByUserId(userId);

        Map map = new HashMap();
        if (veCompanyUser != null) {
            map = this.veCompanyMapper.getCompanyByUserId(Integer.valueOf(veCompanyUser.getCpId()));
        }
        return map;
    }

    public PageResponseResult selectCpList(VeCompanyVo veCompanyVo, Integer pageNo, Integer pageSize, VeCommon veCommon)
    {
        List<VeCompany> veCompanyList = this.veCompanyMapper.selectCpList(veCompanyVo, veCommon);
        for (int i = 0; i < veCompanyList.size(); i++)
        {
            List<VePost> postList = this.veCompanyMapper.isCpHavePost(((VeCompany)veCompanyList.get(i)).getId());
            if ((postList == null) || (postList.size() == 0)) {
                veCompanyList.remove(i);
            }
        }
        if ((veCompanyList != null) && (veCompanyList.size() > 0))
        {
            Map<String, Object> pageData = PagingUtils.getPageData(veCompanyList, pageNo, pageSize);
            List<VeCompany> veCompanyLists = (List)pageData.get("data");
            int totalPage = ((Integer)pageData.get("totalPage")).intValue();
            return new PageResponseResult(pageNo, totalPage, veCompanyList.size(), Result.OK(veCompanyLists));
        }
        return new PageResponseResult(Integer.valueOf(1), 1, 0, Result.OK());
    }

    public Result<?> unityRemoveBatchById(String id)
    {
        if ((id != null) && (!"".equals(id))) {
            unityRemoveBatchByCpid(id);
        }
        return Result.OK("删除成功");
    }

    private void unityRemoveBatchByCpid(String cpId)
    {
        List<VePost> postList = this.veCompanyMapper.getPostByCpId(cpId);
        Iterator localIterator;
        if ((postList != null) && (postList.size() > 0)) {
            for (localIterator = postList.iterator(); localIterator.hasNext();)
            {
                //lbh 2024/07/31 vePost >> VePost vePost
                VePost vePost = (VePost)localIterator.next();
                this.vePostService.removeById(Integer.valueOf(vePost.getId()));
            }
        }
        //lbh 2024/07/31 VePost >> Iterator
        Iterator vePost;
        Object veCompanyUserAdminList = this.veCompanyMapper.getCpUserAdminByCpId(cpId);
        if ((veCompanyUserAdminList != null) && (((List)veCompanyUserAdminList).size() > 0)) {
            for (vePost = ((List)veCompanyUserAdminList).iterator(); vePost.hasNext();)
            {
                //lbh 2024/07/31 veCompanyUser >> VeCompanyUser veCompanyUser
                VeCompanyUser veCompanyUser = (VeCompanyUser)vePost.next();
                Result<?> result = this.veCommonClient.deleteAppUser("09d5e1e7f9b049008eee645c783a1d67", veCompanyUser.getUserId());
                if (result.getCode().equals(Integer.valueOf(200))) {
                    this.veCompanyUserService.removeById(Integer.valueOf(veCompanyUser.getId()));
                }
            }
        }
        VeCompanyUser veCompanyUser;
        List<VeCompanyUser> veCompanyUserTeacherList = this.veCompanyMapper.getCpUserTeacherByCpId(cpId);
        if ((veCompanyUserTeacherList != null) && (veCompanyUserTeacherList.size() > 0)) {
            //lbh 2024/07/31 veCompanyUser >> veCompanyUser1
            for (VeCompanyUser veCompanyUser1 : veCompanyUserTeacherList)
            {
                Result<?> result = this.veCommonClient.deleteAppUser("09d5e1e7f9b049008eee645c783a1d67", veCompanyUser1.getUserId());
                if (result.getCode().equals(Integer.valueOf(200))) {
                    this.veCompanyUserService.removeById(Integer.valueOf(veCompanyUser1.getId()));
                }
            }
        }
        this.veCompanyService.removeById(cpId);
    }

    public Result<?> cpAdmincpNameEcho(String userId, String userType)
    {
        if (userType.equals("3"))
        {
            VeCompanyUser cpUserByUserId = this.veCompanyMapper.getCpUserByUserId(userId);
            return Result.OK(Integer.valueOf(cpUserByUserId.getCpId()));
        }
        return Result.OK();
    }
}
